home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 934 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: Marian Hellema <marian@atcmp.nl>
  2. Message-ID: <4jr0ur$bdh@wn1.sci.kun.nl>
  3. X-Original-Date: 2 Apr 1996 10:53:15 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 02 Apr 96 13:34:59 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Syntax for template instantiation and specialization
  9. Organization: AT Computing, Nijmegen, the Netherlands
  10. X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
  11. X-Url: news:comp.std.c++/19480-19494?ALL
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMWEtEuEDnX0m9pzZAQGulwGAoh2l/ClbhOcl0uZVjmNfvRX1Td1fU4Ta
  14.     W/DEi9pPjFnc5QNNzv2Cp/3txoOYXp+4
  15.     =Da6x
  16.  
  17. Hello,
  18.  
  19. What is the correct syntax for template instantiation and
  20. specialization?
  21.  
  22. From my copy of the DWP April 95 I gather:
  23.  
  24. template<class T>
  25. T max(T a, T b) { return a>b?a:b; }
  26.  
  27. template int max<int>(int, int);    //instantiation
  28. /* OR: */ 
  29. template int max<>(int, int);        //instantiation
  30.  
  31. const char* max<const char*>max(const char* a, const char* b)
  32. {  /* specialization */ }
  33. /* OR: */
  34. const char* max<>(const char* a, const char* b)
  35. {  /* specialization */ }
  36.  
  37. My questions are:
  38. 1. Is the above correct? I heard there are some recent changes
  39. in this area.
  40. 2. Is the following still legal:
  41.    int max(int, int);    //instantiation??
  42.  
  43. Thanks!
  44. Marian
  45.  
  46. -- 
  47. ----------------------------------------------------------------------
  48. Marian Hellema            AT Computing, UNIX training and consultancy
  49. email: marian@atcmp.nl    P.O. Box 1428, 6501 BK Nijmegen
  50. phone: +31 24 3527225     the Netherlands
  51. ---
  52. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  53. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  54. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  55. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  56. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  57.